package string;
/**
 * java.lang.StringBuilder专门用于编辑字符串内容的工具类
 * 其内部维护一个可变的char数组
 * 同时提供了编辑字符串内容的相关操作: 增删改插(含头不含尾)
 */
public class StringBuilderDemo {
    public static void main(String[] args) {
        /*
        StringBuilder builder = new StringBuilder();
        StringBuilder builder1 = new StringBuilder("abc");


        String str = "abc";
        StringBuilder builder2 = new StringBuilder(str);
        String str2 = builder2.toString();

         */

        String str = "好好学习java";
        StringBuilder builder = new StringBuilder(str);

        builder.append(",为了找一个好工作");//增加(额噴嗯)
        System.out.println(builder);

        builder.replace(9,16,"就是为了改变世界");//改(瑞陪死)
        System.out.println(builder);

        builder.delete(0,8);//删(第李特)
        System.out.println(builder);

        builder.insert(0,"活着");//插(而死我特)
        System.out.println(builder);

        builder.reverse();//反转(位哦而死)
        System.out.println(builder);

    }
}
